//
//  NSModelDetailViewController.m
//  Meboo
//
//  Created by kyo on 2024/3/18.
//

#import "NSModelDetailViewController.h"
#import "NSDetailNavView.h"
#import "NSModelDetailView.h"
#import "NSModelDetailLikePassView.h"
@interface NSModelDetailViewController ()
//头部组件 返回和更多操作
@property (nonatomic, strong) NSDetailNavView *conversitionNavView;
//model详情组件
@property(nonatomic,strong) NSModelDetailView *modelDetailView;
//底部like/pass/fc组件
@property(nonatomic,strong) NSModelDetailLikePassView *likePassView;
@end

@implementation NSModelDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = HEXS(@"ffffff");
    self.navigationController.navigationBarHidden = YES;
    [self setupUI];
}

#pragma mark - Public Method
//根据userId 请求model详情数据并刷新页面
- (void)setUserId:(NSString *)userId {
    _userId = userId;
    __WeakSelf
    self.conversitionNavView.userId = userId;
    [[MBLoginDataManager sharedManager] getUserInfoWithCode:userId success:^(BOOL success) {
        if (success && [MBLoginDataManager sharedManager].userInfoModel.userCode) {
            weakSelf.modelDetailView.model = [MBLoginDataManager sharedManager].userInfoModel;
            weakSelf.likePassView.model = [MBLoginDataManager sharedManager].userInfoModel;
        }
    }];
}

//枚举赋值--区分来源
- (void)setModelStyle:(ModelDetailStyle)modelStyle {
    _modelStyle = modelStyle;
    self.likePassView.modelStyle = modelStyle;
}

#pragma mark - Action


#pragma mark - UI
- (void)setupUI {
    
    [self.view addSubview:self.modelDetailView];
    [self.modelDetailView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    
    [self.view addSubview:self.conversitionNavView];
    [self.conversitionNavView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.view);
        make.height.mas_equalTo(StatusBarAndNavigationBarHeight);
    }];
    
    //底部三个按钮的布局
    [self.view addSubview:self.likePassView];
    [self.likePassView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(MBHeightScale(60));
        make.left.right.equalTo(self.view);
        make.bottom.mas_equalTo(-TabbarSafeBottomMargin-MBHeightScale(12));
    }];
}

#pragma mark - Setter && Getter

- (NSDetailNavView *)conversitionNavView {
    if (!_conversitionNavView) {
        _conversitionNavView.modelStyle = self.modelStyle;
        _conversitionNavView = [NSDetailNavView new];
    }
    return _conversitionNavView;
}

- (NSModelDetailView *)modelDetailView {
    if (!_modelDetailView) {
        _modelDetailView = [NSModelDetailView new];
    }
    return _modelDetailView;
}

- (NSModelDetailLikePassView *)likePassView {
    if (!_likePassView) {
        _likePassView = [NSModelDetailLikePassView new];
    }
    return _likePassView;
}
@end
